#ifndef FLUID_FIELD	
#define FLUID_FIELD

#include <vector>
#include <glm/glm.hpp>

class FluidField {
public:

	FluidField ( int w, int h );

	FluidField & operator=( const FluidField & rhs );

	float * GetVel(unsigned int u, unsigned int v);

	void SetVel( unsigned int u, unsigned int v, float * inData );

	float * GetVel(float x, float y);

	void SetVel( float x, float y, float * inData );

	float GetPress( float x, float y );

	void SetPress( float x, float y, float val );

	float GetPress( unsigned int u, unsigned int v );

	void SetPress( unsigned int u, unsigned int v, float val );

	// Sample the field, interpolating to get the value.
	// x and y are between [0, w) and [0, h) respectively
	void SampleField( float x, float y, float * out );

	void Getdim( int & dimX, int & dimy );

	unsigned int GetDimW() const;

	unsigned int GetDimH() const;

	void SolveLaplac( float constMulti, unsigned int iters, FluidField & outField );

private:
	// Bilinearly interpolate a cell
	void BilinInterp( unsigned int cellU, unsigned int cellV, float u, float v, float * out );

	void BilerpV3( float * lowerL, float * lowerR, float * upperR, float * upperL, float u, float v, float * out );

	std::vector<glm::vec3> mVel;

	std::vector< float > mPress;

	glm::ivec2 mDim;
};

#endif